﻿<Window x:Class="DataBinding.AdvancedListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:DataBinding"
    Title="AdvancedListView" Height="600" Width="600"
    >
  <Window.Resources>    
    <local:ImagePathConverter x:Key="ImagePathConverter"></local:ImagePathConverter>
    <local:PriceToBackgroundConverter x:Key="PriceToBackgroundConverter" HighlightBrush="PaleGoldenrod" MinPrice="100"></local:PriceToBackgroundConverter>   
    
  </Window.Resources>

  <Grid>
    <ListView Margin="5" Name="lstProducts" GridViewColumnHeader.Click="gridViewColumn_Click">      
      <!--<ListView.ItemContainerStyle>
        <Style>
          <Setter Property="ListViewItem.Background" Value="{Binding Converter={StaticResource PriceToBackgroundConverter}}" />
        </Style>
      </ListView.ItemContainerStyle>-->
      <ListView.View>        
        <GridView>          
          <GridView.Columns>
            <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=ModelName}" >              
            </GridViewColumn>
            <GridViewColumn Header="Model" DisplayMemberBinding="{Binding Path=ModelNumber}" />
            <GridViewColumn Header="Description" Width="300">
              <GridViewColumn.CellTemplate>
                <DataTemplate>
                  <TextBlock Text="{Binding Path=Description}" TextWrapping="Wrap"></TextBlock>
                </DataTemplate>
              </GridViewColumn.CellTemplate>
            </GridViewColumn>
            <GridViewColumn Header="Picture" >
              <GridViewColumn.CellTemplate>
                <DataTemplate>
                  <Image Source="{Binding Path=ProductImagePath, Converter={StaticResource ImagePathConverter}}"></Image>
                </DataTemplate>
              </GridViewColumn.CellTemplate>
            </GridViewColumn>
            <GridViewColumn Header="Price" DisplayMemberBinding="{Binding Path=UnitCost, StringFormat={}{0:C} }" >              
            </GridViewColumn>
          </GridView.Columns>
        </GridView>
      </ListView.View>
    </ListView>
  </Grid>
</Window>

